package com.aree.caipiao.shsq.action;

import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.aree.caipiao.shsq.dao.IShuangSeQiuResultDao;

/**
 * 数据分析的请求响应
 * @author Chengpeng.zhang
 *
 */
public class AnalizyController {
	private static Log log = LogFactory.getLog(AnalizyController.class);
	
	private IShuangSeQiuResultDao shuangSeQiuResultDao;
	
	@RequestMapping(value="summary", method=RequestMethod.GET)
	public @ResponseBody Map<Integer, Integer> summary() {
		log.debug("summary enter...");
		// 初始化返回的对象
		Map<Integer, Integer> fenxiResults = null;
		fenxiResults = new TreeMap<Integer, Integer>();
		for (int i = 22; i <= 199; i++) {
			fenxiResults.put(i, 0);
		}
		// 统计和值及出现的频率
		List<Integer> results = shuangSeQiuResultDao.getHezhiTongji();
		for (Integer result : results) {
			int storedTotal = fenxiResults.get(result);
			fenxiResults.put(result, ++storedTotal);
		}
		return fenxiResults;
	}
	
	@RequestMapping(value="/", method=RequestMethod.GET)
	public String test() {
		return "test";
	}
	
}
